package dailyProgram03;

import java.util.ArrayList;
import java.util.Collections;

public class combineNumber {
	public static void main(String[] args) {
		ArrayList<String> list = new ArrayList<String>();
		combineNumber(list,"",'1','4');
		System.out.println(list);
	}

	private static void combineNumber(ArrayList<String> list, String num, char start, char end) {
		if(start == end+1) {
			list.add(num);
		}else {
			for(Character i='1';i<=end;i++) {
				if(contains(num,i)) {
					
				}else {
					combineNumber(list,num+i,(char)(start+1),end);
				}
			}
		}
	}

	private static boolean contains(String num, Character i) {
		boolean flag = false;
		char[] chars = num.toCharArray();
		for(char c:chars) {
			if(c==i) {
				flag = true;
				break;
			}
		}
		return flag;
	}
}
